﻿;v1.0
#NoEnv
#include <Tip>
#SingleInstance Force
Menu, Tray, Icon,,, 1
Menu, tray, NoStandard
Menu, Tray, Color, FFFFFF
Menu, Tray, Tip , 复制工具
Menu, tray, add, 复制记录`tCapsLK+S, 复制记录
Menu, tray, add, 复制提示`tCapsLK+T, 复制备注计时器
Menu, tray, add, 撤回复制`tCapsLK+Z, 撤回复制
Menu, tray, add, 重置剪切板`tCapsLK+R, 重置剪切板
Menu, tray, add, 热键开关`tCapsLK+B, 热键开关
Menu, tray, add, 清空记录
Menu, tray, add, 退出程序`tShift+Esc, 退出
Menu, tray, Default, 复制记录`tCapsLK+S
copy_obj:=[]
rjkg := 1
jsqkg := -1
copy_time := 1
stick_time:= 1

gui, +AlwaysOnTop +ToolWindow +Hwndid
Gui, Add, ListView, x0 y0 r15 w200 g复制选中项 BackgroundDefault ReadOnly  -WantF2 -Multi NoSortHdr, NO|内容
return

GuiContextMenu:
menu, tray, Show
return


CapsLock & z::
撤回复制:
copy_obj.Pop()
Clipboard:=copy_obj[copy_obj.Length()]
Tip("已撤回上一次复制内容", 1000)
copy_time-=1
return

!q::
send ^s
Reload
return

复制选中项:
if A_GuiEvent =DoubleClick
{
	if A_EventInfo 
	{
		LV_GetText(a, A_EventInfo , 2)
		Clipboard:=a
		Tip("已复制选中记录" "`n" "使用CapsLk+A粘贴" "`n`n`n"  Clipboard, 1000)
	}
}
return

CapsLock & s::
复制记录:
if WinActive("ahk_id" id)
	gui, Cancel
else
	gui, Show, w200 h250, 复制记录
return

清空记录:
LV_Delete()
return

CapsLock & t::
复制备注计时器:
jsqkg:=jsqkg * -1
if jsqkg=1
	SetTimer, 复制备注, 1
else
{
	SetTimer, 复制备注, OFF
	tooltip
}
return

复制备注:
lb:=copy_time - stick_time
lb2:=copy_time - 1
ToolTip,已拷贝%lb2%次/未粘贴%lb%
exit

CapsLock & a::
send ^v
return

~$^c::
Sleep, 100
if (copy_obj[copy_obj.Length()] = Clipboard)	
	return
copy_obj.Insert(Clipboard)
copy_time+=1
LV_Add("-Focus", LV_GetCount()+1 ".", Clipboard)
LV_ModifyCol(1, "AutoHdr Center")
return

$^v::
Clipboard:=copy_obj[stick_time]
Sleep,100
send,^v
stick_time+=1

if (stick_time >= copy_time )
{
Tip("粘贴到底啦,已重置", 1000)
gosub 重置剪切板
}
return

CapsLock & r:: ;重置
Tip("已重置", 1000)
重置剪切板:
copy_obj:=[]
stick_time:=1
copy_time:=1
Sleep 1000
return

GuiEscape:
gui, Cancel
return

+Esc::
退出:
ExitApp
return

CapsLock & b::
热键开关:
Suspend
Critical, On
rjkg:= rjkg*(-1)
if rjkg = 1
	MsgBox, 4096, Tip, 热键已开启, 0.5
else
	MsgBox, 4096, Tip, 热键已禁用, 0.5
exit